﻿using HslCommunication.Core;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace qzjxm.Helper
{
    [ConfigFile("Config\\Setting.ini")]

    internal class ConfigHelper: IniConfig<ConfigHelper>
    {
        [ConfigSection("Hello")]
        public string ProtName { get; set; }

        public int BaudRate { get; set; }

        public int DataBits { get; set; }

        public StopBits StopBits { get; set; }
        public Parity Parity { get; set; }
        public bool RtsEnable { get; set; }
        public int ReceiveTimeOut { get; set; }
        public byte Station { get; set; }
        public DataFormat DataFormat { get; set; }
        public bool AddressStartWithZero { get; set; }
        public bool IsClearCacheBeforeRead { get; set; }
        public bool Crc16CheckEnable { get; set; }



        public override void SetDefault()
        {
            base.SetDefault();
            ProtName = "COM2";
            BaudRate = 9600;
            DataBits = 8;
            StopBits = StopBits.One;
            Parity = Parity.None;
            RtsEnable = false;
            ReceiveTimeOut = 5000; // 默认接收超时1秒
            Station = 1; // 默认站号
            DataFormat = DataFormat.CDAB; // 默认数据格式
            AddressStartWithZero = true; // 默认地址从0开始
            IsClearCacheBeforeRead = false;
            Crc16CheckEnable = true; // 默认启用CRC16校验
        }
    }
}
